package com.masterclient.app.businessmodule.minemodule.footprint.adapter

import android.support.v7.widget.RecyclerView
import android.support.v7.widget.StaggeredGridLayoutManager
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.eoner.baselibrary.bean.goods.ProductBean
import com.masterclient.app.R
import com.masterclient.app.modules.goods.adapter.CommonGoodsRecyclerAdapter
import com.masterclient.app.widget.StaggeredGridNoScrollLayoutManager

/**
 * 作者：sean
 * 创建时间：2018/5/22 10:47
 * 功能说明：
 */
class FootPrintAdapter() :BaseQuickAdapter<Pair<String,List<ProductBean>>,BaseViewHolder>(R.layout.item_footprint){

    override fun convert(helper: BaseViewHolder, item: Pair<String,List<ProductBean>>) {
        helper.setText(R.id.tv_date,item.first)

        val recyclerView = helper.getView<RecyclerView>(R.id.recyclerView)
//       if (item !== recyclerView.getTag()){
//           recyclerView.setTag(item)
           val layoutManager = StaggeredGridNoScrollLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)
           recyclerView.setLayoutManager(layoutManager)
//        recyclerView.setItemAnimator(null)
           if( recyclerView.getItemDecorationCount() == 0) {
               recyclerView.addItemDecoration(object : RecyclerView.ItemDecoration() {
               })
           }

//        recyclerView.setHasFixedSize(true)
//        recyclerView.setNestedScrollingEnabled(false)
           val goodRecyclerAdapter = CommonGoodsRecyclerAdapter()
            goodRecyclerAdapter.setStrings("我的足迹")
            recyclerView.setAdapter(goodRecyclerAdapter)
           goodRecyclerAdapter.bindToRecyclerView(recyclerView)
           goodRecyclerAdapter.setNewData(item.second)
//       }

    }

}